﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DatabaseDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome on database test");

            eleve e = new eleve();
            IsenDataClassesDataContext context = new IsenDataClassesDataContext();

            eleve babol = new eleve() { prenom = "Arnaud", nom = "Babol", dateNaissance = DateTime.Now };
            context.eleves.InsertOnSubmit(babol);
          //  babol.nom = "Dupont";
            context.SubmitChanges();
            context.SubmitChanges();
            foreach (eleve item in context.eleves)
            {
                
                Console.WriteLine("{0} {1}", item.prenom, item.nom);          
            }
            matiere misn = new matiere(){nom = "MISN", enseignant = "flanders"};
            context.matieres.InsertOnSubmit(misn);
            context.SubmitChanges();

            note note = new note() { valeur = 6, matiereId = misn.id,eleveId = babol.id};
            context.SubmitChanges();
            context.notes.InsertOnSubmit(note);
            context.SubmitChanges();
            foreach (note item in context.notes)
            {

                Console.WriteLine("{0} {1}", item.eleve.nom, item.valeur);
            }

            Console.Read();




        }
    }
}
